home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_023 / ver30 / def.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  12KB  |  362 lines

  1. /*
  2.  * Name:    MicroEMACS
  3.  *        Common header file.
  4.  * Version:    29
  5.  * Last edit:    14-Feb-86
  6.  * By:        rex::conroy
  7.  *        decvax!decwrl!dec-rhea!dec-rex!conroy
  8.  * 
  9.  * This file is the general header file for all parts
  10.  * of the MicroEMACS display editor. It contains all of the
  11.  * general definitions and macros. It also contains some
  12.  * conditional compilation flags. All of the per-system and
  13.  * per-terminal definitions are in special header files.
  14.  * The most common reason to edit this file would be to zap
  15.  * the definition of CVMVAS or BACKUP.
  16.  */
  17. #include    "sysdef.h"        /* Order is critical.        */
  18. #include    "ttydef.h"
  19. #include    <stdio.h>
  20.  
  21. /*
  22.  * If your system and/or compiler does not support the "void" type
  23.  * then define NO_VOID_TYPE in sysdef.h.  In the absence of some
  24.  * other definition for VOID, the default in that case will be to
  25.  * turn it into an int, which works with most compilers that don't
  26.  * support void.  In the absence of any definition of VOID or
  27.  * NO_VOID_TYPE, the default is to assume void is supported, which
  28.  * should be the case for most modern C compilers.
  29.  */
  30.  
  31. #ifndef VOID
  32. #ifdef NO_VOID_TYPE
  33. #  define VOID int            /* Default for no void is int */
  34. #else
  35. #  define VOID void            /* Just use normal void */
  36. #endif /* NO_VOID_TYPE */
  37. #endif /* VOID */
  38.  
  39. #define    CVMVAS    1            /* C-V, M-V work in pages.    */
  40. #define    BACKUP    0            /* Make backup file.        */
  41.  
  42. /*
  43.  * Table sizes, etc.
  44.  */
  45. #define    NSHASH    31            /* Symbol table hash size.    */
  46. #define    NFILEN    80            /* Length, file name.        */
  47. #define    NBUFN    16            /* Length, buffer name.        */
  48. #define    NLINE    256            /* Length, line.        */
  49. #define    NKBDM    256            /* Length, keyboard macro.    */
  50. #define NMSG    512            /* Length, message buffer.    */
  51. #define    NPAT    80            /* Length, pattern.        */
  52. #define    HUGE    1000            /* A rather large number.    */
  53. #define NSRCH    128            /* Undoable search commands.    */
  54. #define    NXNAME    64            /* Length, extended command.    */
  55.  
  56. /*
  57.  * Universal.
  58.  */
  59. #define    FALSE    0            /* False, no, bad, etc.        */
  60. #define    TRUE    1            /* True, yes, good, etc.    */
  61. #define    ABORT    2            /* Death, ^G, abort, etc.    */
  62.  
  63. /*
  64.  * These flag bits keep track of
  65.  * some aspects of the last command. The CFCPCN
  66.  * flag controls goal column setting. The CFKILL
  67.  * flag controls the clearing versus appending
  68.  * of data in the kill buffer.
  69.  */
  70. #define    CFCPCN    0x0001            /* Last command was C-P, C-N    */
  71. #define    CFKILL    0x0002            /* Last command was a kill    */
  72.  
  73. /*
  74.  * File I/O.
  75.  */
  76. #define    FIOSUC    0            /* Success.            */
  77. #define    FIOFNF    1            /* File not found.        */
  78. #define    FIOEOF    2            /* End of file.            */
  79. #define    FIOERR    3            /* Error.            */
  80.  
  81. /*
  82.  * Directory I/O.
  83.  */
  84. #define    DIOSUC    0            /* Success.            */
  85. #define    DIOEOF    1            /* End of file.            */
  86. #define    DIOERR    2            /* Error.            */
  87.  
  88. /*
  89.  * Display colors.
  90.  */
  91. #define    CNONE    0            /* Unknown color.        */
  92. #define    CTEXT    1            /* Text color.            */
  93. #define    CMODE    2            /* Mode line color.        */
  94.  
  95. /*
  96.  * Flags for "eread".
  97.  */
  98. #define    EFNEW    0x0001            /* New prompt.            */
  99. #define    EFAUTO    0x0002            /* Autocompletion enabled.    */
  100. #define    EFCR    0x0004            /* Echo CR at end; last read.    */
  101.  
  102. /*
  103.  * Keys are represented inside using an 11 bit
  104.  * keyboard code. The transformation between the keys on
  105.  * the keyboard and 11 bit code is done by terminal specific
  106.  * code in the "kbd.c" file. The actual character is stored
  107.  * in 8 bits (DEC multinationals work); there is also a control
  108.  * flag KCTRL, a meta flag KMETA, and a control-X flag KCTLX.
  109.  * ASCII control characters are always represented using the
  110.  * KCTRL form. Although the C0 control set is free, it is
  111.  * reserved for C0 controls because it makes the communication
  112.  * between "getkey" and "getkbd" easier. The funny keys get
  113.  * mapped into the C1 control area.
  114.  */
  115. #define    NKEYS    2048            /* 11 bit code.            */
  116.  
  117. #define    METACH    0x1B            /* M- prefix,   Control-[, ESC    */
  118. #define    CTMECH    0x1C            /* C-M- prefix, Control-\    */
  119. #define    EXITCH    0x1D            /* Exit level,  Control-]    */
  120. #define    CTRLCH    0x1E            /* C- prefix,    Control-^    */
  121. #define    HELPCH    0x1F            /* Help key,    Control-_    */
  122.  
  123. #define    KCHAR    0x00FF            /* The basic character code.    */
  124. #define    KCTRL    0x0100            /* Control flag.        */
  125. #define    KMETA    0x0200            /* Meta flag.            */
  126. #define    KCTLX    0x0400            /* Control-X flag.        */
  127.  
  128. #define    KFIRST    0x0080            /* First special.        */
  129. #define    KLAST    0x009F            /* Last special.        */
  130.  
  131. #define    KRANDOM    0x0080            /* A "no key" code.        */
  132. #define    K01    0x0081            /* Use these names to define    */
  133. #define    K02    0x0082            /* the special keys on your    */
  134. #define    K03    0x0083            /* terminal.            */
  135. #define    K04    0x0084
  136. #define    K05    0x0085
  137. #define    K06    0x0086
  138. #define    K07    0x0087
  139. #define    K08    0x0088
  140. #define    K09    0x0089
  141. #define    K0A    0x008A
  142. #define    K0B    0x008B
  143. #define    K0C    0x008C
  144. #define    K0D    0x008D
  145. #define    K0E    0x008E
  146. #define    K0F    0x008F
  147. #define    K10    0x0090
  148. #define    K11    0x0091
  149. #define    K12    0x0092
  150. #define    K13    0x0093
  151. #define    K14    0x0094
  152. #define    K15    0x0095
  153. #define    K16    0x0096
  154. #define    K17    0x0097
  155. #define    K18    0x0098
  156. #define    K19    0x0099
  157. #define    K1A    0x009A
  158. #define    K1B    0x009B
  159. #define    K1C    0x009C
  160. #define    K1D    0x009D
  161. #define    K1E    0x009E
  162. #define    K1F    0x009F
  163.  
  164. /*
  165.  * These flags, and the macros below them,
  166.  * make up a do-it-yourself set of "ctype" macros that
  167.  * understand the DEC multinational set, and let me ask
  168.  * a slightly different set of questions.
  169.  */
  170. #define    _W    0x01            /* Word.            */
  171. #define    _U    0x02            /* Upper case letter.        */
  172. #define    _L    0x04            /* Lower case letter.        */
  173. #define    _C    0x08            /* Control.            */
  174.  
  175. #define    ISWORD(c)    ((cinfo[(c)]&_W)!=0)
  176. #define    ISCTRL(c)    ((cinfo[(c)]&_C)!=0)
  177. #define    ISUPPER(c)    ((cinfo[(c)]&_U)!=0)
  178. #define    ISLOWER(c)    ((cinfo[(c)]&_L)!=0)
  179. #define    TOUPPER(c)    ((c)-0x20)
  180. #define    TOLOWER(c)    ((c)+0x20)
  181.  
  182. /*
  183.  * The symbol table links editing functions
  184.  * to names. Entries in the key map point at the symbol
  185.  * table entry. A reference count is kept, but it is
  186.  * probably next to useless right now. The old type code,
  187.  * which was not being used and probably not right
  188.  * anyway, is all gone.
  189.  */
  190. typedef    struct    SYMBOL {
  191.     struct    SYMBOL *s_symp;        /* Hash chain.            */
  192.     short    s_nkey;            /* Count of keys bound here.    */
  193.     char    *s_name;        /* Name.            */
  194.     int    (*s_funcp)();        /* Function.            */
  195. }    SYMBOL;
  196.  
  197. /*
  198.  * There is a window structure allocated for
  199.  * every active display window. The windows are kept in a
  200.  * big list, in top to bottom screen order, with the listhead at
  201.  * "wheadp". Each window contains its own values of dot and mark.
  202.  * The flag field contains some bits that are set by commands
  203.  * to guide redisplay; although this is a bit of a compromise in
  204.  * terms of decoupling, the full blown redisplay is just too
  205.  * expensive to run for every input character. 
  206.  */
  207. typedef    struct    WINDOW {
  208.     struct    WINDOW *w_wndp;        /* Next window            */
  209.     struct    BUFFER *w_bufp;        /* Buffer displayed in window    */
  210.     struct    LINE *w_linep;        /* Top line in the window    */
  211.     struct    LINE *w_dotp;        /* Line containing "."        */
  212.     short    w_doto;            /* Byte offset for "."        */
  213.     struct    LINE *w_markp;        /* Line containing "mark"    */
  214.     short    w_marko;        /* Byte offset for "mark"    */
  215.     char    w_toprow;        /* Origin 0 top row of window    */
  216.     char    w_ntrows;        /* # of rows of text in window    */
  217.     char    w_force;        /* If NZ, forcing row.        */
  218.     char    w_flag;            /* Flags.            */
  219. }    WINDOW;
  220.  
  221. /*
  222.  * Window flags are set by command processors to
  223.  * tell the display system what has happened to the buffer
  224.  * mapped by the window. Setting "WFHARD" is always a safe thing
  225.  * to do, but it may do more work than is necessary. Always try
  226.  * to set the simplest action that achieves the required update.
  227.  * Because commands set bits in the "w_flag", update will see
  228.  * all change flags, and do the most general one.
  229.  */
  230. #define    WFFORCE    0x01            /* Force reframe.        */
  231. #define    WFMOVE    0x02            /* Movement from line to line.    */
  232. #define    WFEDIT    0x04            /* Editing within a line.    */
  233. #define    WFHARD    0x08            /* Better to a full display.    */
  234. #define    WFMODE    0x10            /* Update mode line.        */
  235.  
  236. /*
  237.  * Text is kept in buffers. A buffer header, described
  238.  * below, exists for every buffer in the system. The buffers are
  239.  * kept in a big list, so that commands that search for a buffer by
  240.  * name can find the buffer header. There is a safe store for the
  241.  * dot and mark in the header, but this is only valid if the buffer
  242.  * is not being displayed (that is, if "b_nwnd" is 0). The text for
  243.  * the buffer is kept in a circularly linked list of lines, with
  244.  * a pointer to the header line in "b_linep".
  245.  */
  246. typedef    struct    BUFFER {
  247.     struct    BUFFER *b_bufp;        /* Link to next BUFFER        */
  248.     struct    LINE *b_dotp;        /* Link to "." LINE structure    */
  249.     short    b_doto;            /* Offset of "." in above LINE    */
  250.     struct    LINE *b_markp;        /* The same as the above two,    */
  251.     short    b_marko;        /* but for the "mark"        */
  252.     struct    LINE *b_linep;        /* Link to the header LINE    */
  253.     char    b_nwnd;            /* Count of windows on buffer    */
  254.     char    b_flag;            /* Flags            */
  255.     char    b_fname[NFILEN];    /* File name            */
  256.     char    b_bname[NBUFN];        /* Buffer name            */
  257. }    BUFFER;
  258.  
  259. #define    BFCHG    0x01            /* Changed.            */
  260. #define    BFBAK    0x02            /* Need to make a backup.    */
  261.  
  262. /*
  263.  * This structure holds the starting position
  264.  * (as a line/offset pair) and the number of characters in a
  265.  * region of a buffer. This makes passing the specification
  266.  * of a region around a little bit easier.
  267.  * There have been some complaints that the short in this
  268.  * structure is wrong; that a long would be more appropriate.
  269.  * I'll awat more comments from the folks with the little
  270.  * machines; I have a VAX, and everything fits.
  271.  */
  272. typedef    struct    {
  273.     struct    LINE *r_linep;        /* Origin LINE address.        */
  274.     short    r_offset;        /* Origin LINE offset.        */
  275.     short    r_size;            /* Length in characters.    */
  276. }    REGION;
  277.  
  278. /*
  279.  * All text is kept in circularly linked
  280.  * lists of "LINE" structures. These begin at the
  281.  * header line (which is the blank line beyond the
  282.  * end of the buffer). This line is pointed to by
  283.  * the "BUFFER". Each line contains a the number of
  284.  * bytes in the line (the "used" size), the size
  285.  * of the text array, and the text. The end of line
  286.  * is not stored as a byte; it's implied. Future
  287.  * additions will include update hints, and a
  288.  * list of marks into the line.
  289.  */
  290. typedef    struct    LINE {
  291.     struct    LINE *l_fp;        /* Link to the next line    */
  292.     struct    LINE *l_bp;        /* Link to the previous line    */
  293.     short    l_size;            /* Allocated size        */
  294.     short    l_used;            /* Used size            */
  295. #if    PCC
  296.     char    l_text[1];        /* A bunch of characters.    */
  297. #else
  298.     char    l_text[];        /* A bunch of characters.    */
  299. #endif
  300. }    LINE;
  301.  
  302. /*
  303.  * The rationale behind these macros is that you
  304.  * could (with some editing, like changing the type of a line
  305.  * link from a "LINE *" to a "REFLINE", and fixing the commands
  306.  * like file reading that break the rules) change the actual
  307.  * storage representation of lines to use something fancy on
  308.  * machines with small address spaces.
  309.  */
  310. #define    lforw(lp)    ((lp)->l_fp)
  311. #define    lback(lp)    ((lp)->l_bp)
  312. #define    lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  313. #define    lputc(lp, n, c)    ((lp)->l_text[(n)]=(c))
  314. #define    llength(lp)    ((lp)->l_used)
  315.  
  316. /*
  317.  * Externals.
  318.  */
  319. extern    int    thisflag;
  320. extern    int    lastflag;
  321. extern    int    curgoal;
  322. extern    int    epresf;
  323. extern    int    sgarbf;
  324. extern    WINDOW    *curwp;
  325. extern    BUFFER    *curbp;
  326. extern    WINDOW    *wheadp;
  327. extern    BUFFER    *bheadp;
  328. extern    BUFFER    *blistp;
  329. extern    short    kbdm[];
  330. extern    short    *kbdmip;
  331. extern    short    *kbdmop;
  332. extern    char    pat[];
  333. extern    SYMBOL    *symbol[];
  334. extern    SYMBOL    *binding[];
  335. extern    BUFFER    *bfind();
  336. extern    BUFFER    *bcreate();
  337. extern    WINDOW    *wpopup();
  338. extern    LINE    *lalloc();
  339. extern  int    nrow;
  340. extern  int    ncol;
  341. extern    char    *version[];
  342. extern    int    ttrow;
  343. extern    int    ttcol;
  344. extern    int    tceeol;
  345. extern    int    tcinsl;
  346. extern    int    tcdell;
  347. extern    char    cinfo[];
  348. extern    char    *keystrings[];
  349. extern    SYMBOL    *symlookup();
  350. extern    int    nmsg;
  351. extern    int    curmsgf;
  352. extern    int    newmsgf;
  353. extern    char    msg[];
  354.  
  355. /*
  356.  * Standard I/O.
  357.  */
  358. extern    char    *malloc();
  359. extern    char    *strcpy();
  360. extern    char    *strcat();
  361.  
  362.